#include "stdafx.h"
#include "ODBCHandler.h"

ODBCHandler::ODBCHandler(SQLHANDLE input_handel, SQLSMALLINT handle_type)
    : handler_type_(handle_type)
{
    SQLRETURN rc = SQLAllocHandle(handle_type, input_handel, &handler_);

	if (SQL_SUCCEEDED(rc) == false)
	{
		SQLSMALLINT err_msg_len = 0;
		SQLINTEGER err_native = 0;
		UCHAR err_msg[2048] = { 0 };
		UCHAR err_state[256] = { 0 };

		SQLGetDiagRecA(SQL_HANDLE_DBC, input_handel, 1, err_state, &err_native, err_msg, sizeof(err_msg), &err_msg_len);
		LOG(ERROR) << "err_msg: " << err_msg;
	}
}

ODBCHandler::~ODBCHandler()
{
    SQLFreeHandle(handler_type_, handler_);
}

